package main

import (
	"context"
	"plusplus/src"

	"github.com/wailsapp/wails/v2/pkg/runtime"
)

// App struct
type App struct {
	ctx context.Context
}

// NewApp creates a new App application struct
func NewApp() *App {
	return &App{}
}

// startup is called at application startup
func (a *App) startup(ctx context.Context) {
	// Perform your setup here
	a.ctx = ctx
	runtime.WindowMaximise(a.ctx)
}

// domReady is called after front-end resources have been loaded
func (a App) domReady(ctx context.Context) {
	// Add your action here
}

// beforeClose is called when the application is about to quit,
// either by clicking the window close button or calling runtime.Quit.
// Returning true will cause the application to continue, false will continue shutdown as normal.
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
	return false
}

// shutdown is called at application termination
func (a *App) shutdown(ctx context.Context) {
	// Perform your teardown here
}

// Greet returns num + 2
func (a *App) Greet(num int) int {
	return num + 2
}

func (a *App) GetReport() src.Response {
	src.Logger.Info("获取所有仓库")
	access_token := src.GetIniConfig("gitcode", "access_token")
	resp := src.GetReports("https://api.gitcode.com/api/v5/user/repos", map[string]string{"access_token": access_token})
	//println(resp.ToString())
	src.Logger.Info("app.go 49 line ,请求成功")
	//src.Logger.Info(resp.ToString())
	return resp
}
